<template>
  <div>
  
  </div>
</template>

<script>
import dictionaryAPI from "@/api/dictionary";
export default {

  data() {
    return {
      dic: null,
      title:"",

      // 字典内容列表数据
      valusList: [],
      // 添加数据表单
      addDictionaryValueForm: {
        label: "",
        value: "",
        comment:"",
        update: true,
        remove: true,
      },
    };
  },

  created() {
    let dic = this.$route.query.dic;
    let title = this.$route.query.title;
    this.dic = dic;
    this.title = "字典：" + title
    this.getDicValueList();
  },

  methods: {
    getDicValueList() {
      let dic_id = this.dic;
      dictionaryAPI.dictionaryValueList({ dic_id }).then((res) => {
        let data = res.data;
        this.valusList = data;
      });
    },
    // 新增字典内容
    addDicValue() {
      let dic_id = this.dic;
      let label = this.addDictionaryValueForm.label;
      let value = this.addDictionaryValueForm.value;
      let comment = this.addDictionaryValueForm.comment;
      let update = this.addDictionaryValueForm.update;
      let remove = this.addDictionaryValueForm.remove;
      dictionaryAPI
        .addDictionaryValue({ dic_id, label, value, comment, update, remove })
        .then((res) => {
          let { msg } = res;
          this.$message({
            message: msg,
            type: "success",
          });
          this.getDicValueList();
        })
        .catch((err) => {
          let { msg } = err;
          this.$message({
            message: msg,
            type: "error",
          });
        });
    },
  },
};
</script>

<style></style>
